package Behaviour;

import java.awt.Point;

import Model.Edge;
import map.Map;
import jade.core.behaviours.OneShotBehaviour;

public class UpdateWeightedEdge extends OneShotBehaviour {
	

	private static final long serialVersionUID = 3735172148899581967L;
	private Map map ;
	
	public UpdateWeightedEdge(Map map) {
		this.map = map;
	}
	
	@Override
	public void action() {
		for (Edge edge : map.getCrossRoadsGraph().edgeSet()) {
			int numCar = 0;
			for (Point ePoint : edge.getEdgePoints()) {
				if(map.getMap()[ePoint.x][ePoint.y].isOccupied())
					numCar++;
			}
			map.getCrossRoadsGraph().setEdgeWeight(edge, numCar);
			
		}
	}

}
